#ifndef _DOUBLY_LINKED_LIST_H_
#define _DOUBLY_LINKED_LIST_H_
#include <stddef.h>

typedef struct Node_t {
  struct Node_t *prev;
  struct Node_t *next;
  char data[0];
} Node;

typedef struct doubly_linked_list_t {
  Node *head;
  size_t size;
  size_t nmemb;
} DLList;

typedef int (*cmp_t)(const void *, const void *);
typedef void (*trave_t)(const void *);

int DLList_init(DLList **list, size_t size);

int DLList_insert_back(DLList *list, void *new_data);

int DLList_insert_front(DLList *list, void *new_data);

void *DLList_get(const DLList *list, size_t index);

int DLList_mod(DLList *list, size_t index, void *new_data);

int DLList_del(DLList *list, void *del_data, cmp_t cmp);

int DLList_search(const DLList *list, void *data, cmp_t cmp);

int DLList_free(DLList **list);

int DLList_trave(const DLList *list, trave_t trave);

#endif // !_DOUBLY_LINKED_LIST_H_
